package com.keyancompany.zhongbaopingtai.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.adapter.IFragmentPagerAdapter;
import com.keyancompany.zhongbaopingtai.fragment.PublishPackageItemFragment;
import com.keyancompany.zhongbaopingtai.utils.IntentUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.BindString;

/**
 * 我的项目
 */
public class PublishPackageActivity extends BaseActivity {
    @BindString(R.string.my_publish_package_text)
    String title;
    @Bind(R.id.toolbar)
    Toolbar toolbar;

    @Bind(R.id.tabLayout)
    TabLayout tabLayout;
    @Bind(R.id.complaint_viewpager)
    ViewPager complaintViewpager;
    List<Fragment> tcf = new ArrayList<>();

    @Override
    protected int getContentViewId() {
        return R.layout.activity_complaint;
    }

    @Override
    protected int getMenuId() {
        return R.menu.publish_package_menu;
    }

    @Override
    protected void initToolBar() {
        initToolBar(toolbar, title);
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.action_publish_package:
//                        T.showShort(mContext, "发布");
                        IntentUtils.startActivity(mContext, CreatePackageActivity.class);
                        break;
                }
                return true;
            }
        });
    }

    @Override
    protected void setUpViews() {
        tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));


        tcf.add(PublishPackageItemFragment.newInstance(PublishPackageItemFragment.TYPE_CREATE));
        tcf.add(PublishPackageItemFragment.newInstance(PublishPackageItemFragment.TYPE_INJION));
        IFragmentPagerAdapter pagerAdapter = new IFragmentPagerAdapter(getSupportFragmentManager(), tcf);
        pagerAdapter.setTitles(new String[]{"我发布的", "我参与的"});
        complaintViewpager.setAdapter(pagerAdapter);
        tabLayout.setupWithViewPager(complaintViewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    }

}
